package com.probiz.estore.common.model.customer.base;

import java.io.Serializable;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import com.probiz.estore.common.model.customer.Address;

/**
 * Address Base Java Bean, base class for the model, mapped directly to database table
 * 
 * Avoid changing this file if not necessary, will be overwritten. 
 *
 */
public class AddressTbl extends com.probiz.estore.core.model.BaseObject implements Serializable {

    protected Integer addressId;
	protected Short addressType;
	protected String title;
	protected String firstname;
	protected String lastname;
	protected String email;
	protected String telephone;
	protected String zip;
	protected String fax;
	protected String companyName;
	protected Short isDefaultShippingAddress;
	protected Short isDefaultBillingAddress;
	protected String address;
	protected String address2;
	protected Integer regionId;
	protected String regionFullName;
	protected Integer userDefinedId;
	protected com.probiz.estore.common.model.system.AppUser appUser;

	protected java.util.Set wishlists = new java.util.HashSet();

	/**
	 * Default Empty Constructor for class Address
	 */
	public AddressTbl () {
		super();
	}
	
	/**
	 * Default Key Fields Constructor for class Address
	 */
	public AddressTbl (
		 Integer in_addressId
        ) {
		this.setAddressId(in_addressId);
    }

	
	public com.probiz.estore.common.model.system.AppUser getAppUser () {
		return appUser;
	}	
	
	public void setAppUser (com.probiz.estore.common.model.system.AppUser in_appUser) {
		this.appUser = in_appUser;
	}

	public java.util.Set getWishlists () {
		return wishlists;
	}	
	
	public void setWishlists (java.util.Set in_wishlists) {
		this.wishlists = in_wishlists;
	}
    

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	/**
	 * @return Integer
     * @hibernate.id column="addressId" type="java.lang.Integer" generator-class="native"
	 */
	public Integer getAddressId() {
		return this.addressId;
	}
	
	/**
	 * Set the addressId
	 */	
	public void setAddressId(Integer aValue) {
		this.addressId = aValue;
	}	

	/**
	 * @return Integer
	 */
	public Integer getAppuserId() {
		return this.getAppUser()==null?null:this.getAppUser().getAppuserId();
	}
	
	/**
	 * Set the appuserId
	 */	
	public void setAppuserId(Integer aValue) {
	    if (aValue==null) {
	    	appUser = null;
	    } else if (appUser == null) {
	        appUser = new com.probiz.estore.common.model.system.AppUser(aValue);
	        appUser.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
	    } else {
			appUser.setAppuserId(aValue);
	    }
	}	

	/**
	 * @return Short
	 * @hibernate.property column="addressType" type="java.lang.Short" length="6" not-null="true" unique="false"
	 */
	public Short getAddressType() {
		return this.addressType;
	}
	
	/**
	 * Set the addressType
	 * @spring.validator type="required"
	 */	
	public void setAddressType(Short aValue) {
		this.addressType = aValue;
	}	

	/**
	 * @return String
	 * @hibernate.property column="title" type="java.lang.String" length="8" not-null="false" unique="false"
	 */
	public String getTitle() {
		return this.title;
	}
	
	/**
	 * Set the title
	 */	
	public void setTitle(String aValue) {
		this.title = aValue;
	}	

	/**
	 * @return String
	 * @hibernate.property column="firstname" type="java.lang.String" length="32" not-null="false" unique="false"
	 */
	public String getFirstname() {
		return this.firstname;
	}
	
	/**
	 * Set the firstname
	 */	
	public void setFirstname(String aValue) {
		this.firstname = aValue;
	}	

	/**
	 * @return String
	 * @hibernate.property column="lastname" type="java.lang.String" length="32" not-null="false" unique="false"
	 */
	public String getLastname() {
		return this.lastname;
	}
	
	/**
	 * Set the lastname
	 */	
	public void setLastname(String aValue) {
		this.lastname = aValue;
	}	

	/**
	 * @return String
	 * @hibernate.property column="telephone" type="java.lang.String" length="32" not-null="false" unique="false"
	 */
	public String getTelephone() {
		return this.telephone;
	}
	
	/**
	 * Set the telephone
	 */	
	public void setTelephone(String aValue) {
		this.telephone = aValue;
	}	

	/**
	 * @return String
	 * @hibernate.property column="zip" type="java.lang.String" length="6" not-null="false" unique="false"
	 */
	public String getZip() {
		return this.zip;
	}
	
	/**
	 * Set the zip
	 */	
	public void setZip(String aValue) {
		this.zip = aValue;
	}	

	/**
	 * @return String
	 * @hibernate.property column="fax" type="java.lang.String" length="32" not-null="false" unique="false"
	 */
	public String getFax() {
		return this.fax;
	}
	
	/**
	 * Set the fax
	 */	
	public void setFax(String aValue) {
		this.fax = aValue;
	}	

	/**
	 * @return String
	 * @hibernate.property column="companyName" type="java.lang.String" length="128" not-null="false" unique="false"
	 */
	public String getCompanyName() {
		return this.companyName;
	}
	
	/**
	 * Set the companyName
	 */	
	public void setCompanyName(String aValue) {
		this.companyName = aValue;
	}	

	/**
	 * @return Short
	 * @hibernate.property column="isDefaultShippingAddress" type="java.lang.Short" length="6" not-null="false" unique="false"
	 */
	public Short getIsDefaultShippingAddress() {
		return this.isDefaultShippingAddress;
	}
	
	/**
	 * Set the isDefaultShippingAddress
	 */	
	public void setIsDefaultShippingAddress(Short aValue) {
		this.isDefaultShippingAddress = aValue;
	}	

	/**
	 * @return Short
	 * @hibernate.property column="isDefaultBillingAddress" type="java.lang.Short" length="6" not-null="false" unique="false"
	 */
	public Short getIsDefaultBillingAddress() {
		return this.isDefaultBillingAddress;
	}
	
	/**
	 * Set the isDefaultBillingAddress
	 */	
	public void setIsDefaultBillingAddress(Short aValue) {
		this.isDefaultBillingAddress = aValue;
	}	

	/**
	 * @return String
	 * @hibernate.property column="address" type="java.lang.String" length="128" not-null="true" unique="false"
	 */
	public String getAddress() {
		return this.address;
	}
	
	/**
	 * Set the address
	 * @spring.validator type="required"
	 */	
	public void setAddress(String aValue) {
		this.address = aValue;
	}	

	/**
	 * @return String
	 * @hibernate.property column="address2" type="java.lang.String" length="128" not-null="false" unique="false"
	 */
	public String getAddress2() {
		return this.address2;
	}
	
	/**
	 * Set the address2
	 */	
	public void setAddress2(String aValue) {
		this.address2 = aValue;
	}	

	
	
	public Integer getRegionId() {
		return regionId;
	}

	public void setRegionId(Integer regionId) {
		this.regionId = regionId;
	}

	public String getRegionFullName() {
		return regionFullName;
	}

	public void setRegionFullName(String regionFullName) {
		this.regionFullName = regionFullName;
	}

	/**
	 * @return Integer
	 * @hibernate.property column="userDefinedId" type="java.lang.Integer" length="11" not-null="false" unique="false"
	 */
	public Integer getUserDefinedId() {
		return this.userDefinedId;
	}
	
	/**
	 * Set the userDefinedId
	 */	
	public void setUserDefinedId(Integer aValue) {
		this.userDefinedId = aValue;
	}	

	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof Address)) {
			return false;
		}
		Address rhs = (Address) object;
		return new EqualsBuilder()
				.append(this.addressId, rhs.addressId)
						.append(this.addressType, rhs.addressType)
				.append(this.title, rhs.title)
				.append(this.firstname, rhs.firstname)
				.append(this.lastname, rhs.lastname)
				.append(this.telephone, rhs.telephone)
				.append(this.zip, rhs.zip)
				.append(this.fax, rhs.fax)
				.append(this.companyName, rhs.companyName)
				.append(this.isDefaultShippingAddress, rhs.isDefaultShippingAddress)
				.append(this.isDefaultBillingAddress, rhs.isDefaultBillingAddress)
				.append(this.address, rhs.address)
				.append(this.address2, rhs.address2)
				.append(this.userDefinedId, rhs.userDefinedId)
				.isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-82280557, -700257973)
				.append(this.addressId) 
						.append(this.addressType) 
				.append(this.title) 
				.append(this.firstname) 
				.append(this.lastname) 
				.append(this.telephone) 
				.append(this.zip) 
				.append(this.fax) 
				.append(this.companyName) 
				.append(this.isDefaultShippingAddress) 
				.append(this.isDefaultBillingAddress) 
				.append(this.address) 
				.append(this.address2) 
				.append(this.userDefinedId) 
				.toHashCode();
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this)
				.append("addressId", this.addressId) 
						.append("addressType", this.addressType) 
				.append("title", this.title) 
				.append("firstname", this.firstname) 
				.append("lastname", this.lastname) 
				.append("telephone", this.telephone) 
				.append("zip", this.zip) 
				.append("fax", this.fax) 
				.append("companyName", this.companyName) 
				.append("isDefaultShippingAddress", this.isDefaultShippingAddress) 
				.append("isDefaultBillingAddress", this.isDefaultBillingAddress) 
				.append("address", this.address) 
				.append("address2", this.address2) 
				.append("userDefinedId", this.userDefinedId) 
				.toString();
	}

	/**
	 * Return the name of the first key column
	 */
	public String getFirstKeyColumnName() {
		return "addressId";
	}
	
}